package com.dituhui.gps.local;

import java.io.IOException;

import com.dituhui.tool.algorithm.UUIDGenerator;
import com.dituhui.tool.io.HttpTool;

import net.sf.json.JSONObject;

public class Qiyeban {

	public static void main(String[] args) throws IOException {
		String tokenPath = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
		String tokenParam = "corpid=wx81273f13f8c42610&corpsecret=8xnlC1emtM1JPL3UMjZwsKRiK5shVPp1gSrKCk1lyT4GooBrUoK4n6Zi1sR1L9gs";
		String tokenResult = HttpTool.getContentByGET(tokenPath, tokenParam);
		JSONObject jsonToken = JSONObject.fromObject(tokenResult);
		String access_token = jsonToken.getString("access_token");
		String ticketPath = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket";
		String ticketParam = "access_token=" + access_token;
		String ticketResult = HttpTool.getContentByGET(ticketPath, ticketParam);
		JSONObject ticketToken = JSONObject.fromObject(ticketResult);
		String ticket = ticketToken.getString("ticket");
		System.out.println("ticket = " + ticket);
		System.out.println("timestamp = " + System.currentTimeMillis());
		System.out.println("noncestr = " + UUIDGenerator.generate());
//		SHA1Util.getSha1(s);
	}

}
